package cn.wolfcode.wolf2w.controller;

import cn.wolfcode.wolf2w.domain.Strategy;
import cn.wolfcode.wolf2w.domain.UserInfo;
import cn.wolfcode.wolf2w.redis.service.IStrategyStatisVORedisService;
import cn.wolfcode.wolf2w.service.IStrategyService;
import cn.wolfcode.wolf2w.util.JsonResult;
import cn.wolfcode.wolf2w.util.UserParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/strategyList")

public class strategyListController {
    @Autowired
    private IStrategyStatisVORedisService strategyStatisVORedisService;
    @Autowired
    private IStrategyService strategyService;

    @GetMapping("/query")
    public Object query(@UserParam UserInfo userInfo) {
        List<Strategy> list1 = new ArrayList<>();

            List<String> list = strategyStatisVORedisService.querySid(userInfo.getId());
            for (String sid : list) {
                Strategy strategy = strategyService.get(sid);
                list1.add(strategy);

            }

        System.out.println(list1);
        return JsonResult.success(list1);
    }
}
